package com.wang.interview.tests.extendtest;

/**
 * @author: wang
 * @date: 2021/8/8 16:13
 * @description: 父类引用子类，子类自动提升为父类型，其实子类和父类用instanceof判断是同一种类型
 */
public class T1 {
    public void pri(){
        System.out.println("123");
    }
}
class T2 extends T1 {
    @Override
    public void pri() {
        System.out.println("456");
    }
}
class T3{
    public static void main(String[] args) {
        T1 t1 = new T2();
        System.out.println( t1 instanceof T1 );  // true
        System.out.println( t1 instanceof T2 );  // true
        t1.pri();                                // 456
        T1 tt1 = (T1)new T2();
        tt1.pri();                               // 456
    }
}
